parser grammar RuleParser;

options {
  language = Java;
  tokenVocab = RuleLexer;
  output = AST;
}

@header 
{
    package org.moflon.moca.rule.parser; 
}


main: (rule NEWLINE NEWLINE)* rule -> ^(MAIN rule*);

rule: lhs=pattern NEWLINE TO NEWLINE rhs=pattern -> ^(RULE ^(BEFORE $lhs) ^(AFTER $rhs));

pattern: (row NEWLINE)* row -> row+;

row:  (tile SEPARATOR)* tile  -> ^(ROW tile+);

tile: THIS -> ^(THIS_FIELD) | DONTCARE -> ^(DONTCARE_FIELD) | EMPTY -> ^(EMPTY_FIELD);
